#ifndef CEcgEvent_H
#define CEcgEvent_H

#ifdef __cplusplus
extern "C" {
#endif

#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <math.h>
#include "RealTimeWarn.h"
#include "EcgFilter.h"

class CEcgEvent
{
private:
	enum {
		maxQRSNUM = 1500,
		WarnlastTime = 1250
	};
	int ModulusWin[15] ;//= { -3,-4,-4, -3,1,5,10,11,10,5,1,-3,-4,-4,-3 };
	int x1 ;//= 0;
	int x2 ;//= 0;
	int x3 ;//= 0;
	int x4 ;//= 0;
	int LpHistX[10] ;//= { 0 };
	int LpHistY[2] ;//= { 0 };
	int HpHistX[32] ;//= { 0 };
	int HpHistY[2] ;//= { 0 };
	int Win_Data[15] ;//= { 0 };
	int indexWin ;//= 0;
	int pMove ;//= 0;
	int sumMove ;//= 0;
	int moveWndBuff[10] ;//= { 0 };
	int MAXpk ;//= 0;
	int lastDatum ;//= 0;
	int timeSinceMax ;//= 0;
	int DDBuffer[DER_BLSCheck] ;//= { 0 };
	int DDPtr ;//= 0;
	int FlagR ;//= 0;
	int DiffData ;//= C_LITTLE_PEAK;
	int Flag_oldDiffData ;//= C_LITTLE_PEAK;
	int Flag_DiffData ;//= C_LITTLE_PEAK;
	int max_DiffData ;//= C_LITTLE_PEAK;

	int temp ;//= 0;

	int Time_sleep ;//= 0;
	int flag_learn_R ;//= 1;//TRUE
	int Time_temp ;//= 0;

	int num_R ;//= 0;
	int QRSNUM ;//= 0;
	int HRrate ;//= 0;

	//
	int Noisearry[15] ;//= { 0 };
	int sortNoisearry[15] ;//= { 0 };
	int scale ;//= 40;
	int TTime ;//= 0;
	/*int lastTTime = TTime;*/
	int BackPeak ;//= 0;
	int BackTime ;//= 0;

	//int ii = 0;
	int Data_II[EcgC] ;//= { 0 };
	int Data_temp[EcgC] ;//= { 0 };
	int InTempEcg ;//= -1;


	int RLocal[maxQRSNUM] ;//= { 0 };
	int QBLocal[maxQRSNUM] ;//= { 0 };
	int SELocal[maxQRSNUM] ;//= { 0 };
	int TELocal[maxQRSNUM] ;//= { 0 };
	int RType[maxQRSNUM] ;//= { 0 };

	int stepLong ;//= 5 * 250;

	int FrequentPVC[5] ;//= { 0 };
	int FrequentPVCNum ;//= 0;
	int MRRInter[5] ;//= { 0 };
	int FrequentPVCQT[5] ;//= { 0 };
	int FrequentPVCRRInter[5] ;//= { 0 };

	int Flag ;//= 0;

	int ADCUnit ;//= 21000;

	//int WarnFlag = 0;
	int Af_Flag ;//= 0;
	int Brad_Flag ;//= 0;
	int RonT_Flag ;//= 0;
	int longQT_Flag ;//= 0;
	int LongRR_Flag ;//= 0;
	int ParoVT_Flag ;//= 0;
	int shortQT_Flag ;//= 0;
	int ST_Flag ;//= 0;
	int SVEBBigeminy_Flag ;//= 0;
	int SVEBCouplet_Flag ;//= 0;
	int SVEBTrigeminy_Flag ;//= 0;
	int SVTA_Flag ;//= 0;
	int VEBBigeminy_Flag ;//= 0;
	int VEBCouplet_Flag ;//= 0;
	int VEBSingle_Flag ;//= 0;
	int VEBTrigeminy_Flag ;//= 0;

	//int WarnTime = 0;
	int Af_Time ;//= 0;
	int Brad_Time ;//= 0;
	int RonT_Time ;//= 0;
	int longQT_Time ;//= 0;
	int LongRR_Time ;//= 0;
	int ParoVT_Time ;//= 0;
	int shortQT_Time ;//= 0;
	int ST_Time ;//= 0;
	int SVEBBigeminy_Time ;//= 0;
	int SVEBCouplet_Time ;//= 0;
	int SVEBTrigeminy_Time ;//= 0;
	int SVTA_Time ;//= 0;
	int VEBBigeminy_Time ;//= 0;
	int VEBCouplet_Time ;//= 0;
	int VEBSingle_Time ;//= 0;
	int VEBTrigeminy_Time ;//= 0;
	RTWResult LastRTW;

public:
	CEcgEvent();
	~CEcgEvent();
	void init();
	void RealTimeWarn(int* FilterData, int LeadNum, int dataLen, RTWResult* RTW);
};

#ifdef __cplusplus
}
#endif

#endif